package com.zhangtingshu.service.impl;

import com.zhangtingshu.dao.CommentDao;
import com.zhangtingshu.pojo.Comment;
import com.zhangtingshu.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

/**
 * @author zhangtingshu
 * 帖子评论逻辑实现类
 */
@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentDao commentDao;

    @Override
    public boolean insert(Comment comment) {
        comment.setCreatedate(new Timestamp(System.currentTimeMillis()));//当前的时间
        return commentDao.insert(comment) > 0 ? true : false;
    }

    @Override
    public List<Comment> findCommentByIid(int iid) {
        return commentDao.findCommentByIid(iid);
    }

    @Override
    public void deleteComment(int id) {
        commentDao.deleteById(id);
    }
}
